using UnityEngine;
using System.Collections;

public class UndoButton : MonoBehaviour {
	
	void Update(){
		if(THistory.Instance.canUndo()){
			gameObject.GetComponent<UIButton>().isEnabled = true;
		}else{
			gameObject.GetComponent<UIButton>().isEnabled = false;
		}
	}
	
	void OnClick(){
		if(!THistory.Instance.isUndoing()){
			GhostsHandler.Instance.spawnAllGhosts();
		}
		THistory.Instance.undo();
		StatsHandler.Instance.addUsedUndo();
	}	
}
